package com.lagou.cl.util;

import java.io.*;

/**
 * @author 程  林
 * @date 2020-06-04 00:20
 * @description //
 * @since V1.0.0
 */
public class Obj2ByteUtil {

	public static long byteArrayToLong(byte[] data) throws IOException {
		ByteArrayInputStream bai = new ByteArrayInputStream(data);
		DataInputStream dis = new DataInputStream(bai);
		return dis.readLong();
	}

	public static byte[] longToByteArray(Long time) throws IOException {
		ByteArrayOutputStream bao = new ByteArrayOutputStream();
		DataOutputStream dos = new DataOutputStream(bao);
		dos.writeLong(time);
		byte[] buf = bao.toByteArray();
		return buf;
	}
}
